import request from "@/router/axios";

import store from "@/store";
export function exportExcel(query) {
  return request({
    url: "/stm/swsttvmcheckdetail/export",
    method: "get",
    params: query,
    responseType: "arraybuffer"
  });
}

export function fetchList(query) {
  return request({
    url: "/stm/swsttvmcheckdetail/page",
    method: "get",
    params: query
  });
}

export function getPeriods(query) {
  return request({
    url: '/check/xw_js_tvm/getPeriods',
    method: 'post',
    params: query
  })
}

export function fetchListBox(query) {
  return request({
    url:
      "/support/swpmtvmcashboxcode/page?size=-1&stationCode=" +
      store.getters.userInfo.stationCode,
    method: "get",
    params: query
  });
}
export function addObj(obj, id) {
  return request({
    url: "/stm/swsttvmcheckdetail/saveorupdate?id=" + id,
    method: "put",
    data: obj,
    id
  });
}

/*export function addObj(obj) {
  return request({
    url: '/stm/swsttvmcheckdetail/update/onecashbox',
    method: 'put',
    data: obj
  })
}*/
export function getObj(id,flag) {
  return request({
    url: `/stm/swsttvmcheckdetail/details/${id}/${flag}`,
    method: "get"
  });
}

export function delObj(id) {
  return request({
    url: "/stm/swsttvmcheckdetail/" + id,
    method: "delete"
  });
}

export function putObj(obj) {
  return request({
    url: "/stm/swsttvmcheckdetail",
    method: "put",
    data: obj
  });
}

export function confirmObj(id) {
  return request({
    url: "/stm/swsttvmcheckdetail/confirmBatch",
    method: "put",
    data: id
  });
}

export function delBatch(id) {
  return request({
    url: "/stm/swsttvmcheckdetail/batchCascadeDel",
    method: "delete",
    data: id
  });
}

export function getTvmCode() {
  return request({
    url:
      "/support/swpmtvmcode/page?size=-1&status=1&stationCode=" +
      store.getters.userInfo.stationCode,
    method: "get"
  });
}

export function getHaveTvmCode(revenueTime, tvmCashBoxType,flag) {
  return request({
    url: `/stm/swsttvmsupplementcurrencydetails/haveTvmCode/${revenueTime}/${tvmCashBoxType}/${flag}`,
    method: "get"
  });
}

export function getHaveCashboxCode(revenueTime,tvmCashBoxType,flag) {
  return request({
    url: `/stm/swsttvmsupplementcurrencydetails/haveTvmCode/${revenueTime}/${tvmCashBoxType}/${flag}`,
    method: "get"
  });
}

//查看TVM钱箱清点数据录入历史记录
export function queryPastRecords(param){
  return request({
    url: '/stm/swsttvmcheckdetail/getLogById/'+param.id,
    method: 'get'
  })
}

//查看TVM钱箱清点数据录入历史记录明细
export function queryPastRecordsDetail(param){
  return request({
    url: '/stm/swsttvmcheckdetail/getLogChildById/'+param.id,
    method: 'get'
  })
}
